Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAB-18192 Fixed TLS certs validation for consenters. #1888

Merged
merged 8 commits into from
Oct 6, 2020

Conversation

kopaygorodsky
Copy link
Contributor

@kopaygorodsky kopaygorodsky commented Sep 17, 2020

Signed-off-by: kopaygorodsky vlad.kopaygorodsky@gmail.com

Type of change

  • Bug fix

Description

Fixes usecase when you add new org with a consenter.
Verification of consenter's TLS certs against simulated config, not the last one. To achieve that, metadata validator interface was changed, now it requires orderer config instead of just consensus metadata. Also, TLS verification was moved to VerifyConfigMetadata function. Added ignoreCertExpiration option to ignore expiration errors when validating config metadata.

Additional details

1.consenter.IsChannelMember returns an error if metadata has a consenter with an invalid certificate or signed by unknown MSP.
2.Added new tests, fixed existing tests.
3.Checked the fix on a test network.

Related issues

https://jira.hyperledger.org/browse/FAB-18192

@kopaygorodsky kopaygorodsky requested a review from a team as a code owner September 17, 2020 00:46
@kopaygorodsky kopaygorodsky force-pushed the FAB-18192 branch 16 times, most recently from e0dba77 to 22d6046 Compare September 21, 2020 21:03
@kopaygorodsky kopaygorodsky force-pushed the FAB-18192 branch 10 times, most recently from ad5d649 to 749bdfa Compare September 25, 2020 13:19
Copy link
Contributor

@wlahti wlahti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this task up! A few general comments that stood out on a first pass.

Going to take a deeper look at the more substantial changes in etcdraft/util.go.

integration/raft/config_test.go Outdated Show resolved Hide resolved
internal/cryptogen/msp/msp.go Outdated Show resolved Hide resolved
integration/raft/config_test.go Outdated Show resolved Hide resolved
integration/raft/config_test.go Outdated Show resolved Hide resolved
orderer/consensus/etcdraft/chain.go Outdated Show resolved Hide resolved
orderer/consensus/etcdraft/consenter_test.go Outdated Show resolved Hide resolved
orderer/consensus/etcdraft/util.go Outdated Show resolved Hide resolved
orderer/consensus/etcdraft/util.go Outdated Show resolved Hide resolved
orderer/consensus/etcdraft/util.go Outdated Show resolved Hide resolved
orderer/consensus/etcdraft/validator_test.go Outdated Show resolved Hide resolved
@kopaygorodsky kopaygorodsky force-pushed the FAB-18192 branch 2 times, most recently from 3d79ab7 to f0325f9 Compare September 28, 2020 11:18
Signed-off-by: kopaygorodsky <vlad.kopaygorodsky@gmail.com>
Copy link
Contributor

@jyellick jyellick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this pull request! It's definitely a bug that we're not validating using the latest config. There are a few points, in particular since we are looking at the full config, and not performing the validation only on the update information, I'm a little concerned about unrelated config updates being rejected because of temporal checks. I've included a comment at the spot, but, I think we could simplify this code by simply skipping the expiration checks. If we are really convinced that they are the right thing to do, then we need to be careful that we only apply them to new certificates in the channel config, and not existing ones. If we apply it to existing ones, then as soon any orderer TLS cert expires, all channel updates would begin failing until the issue is fixed.

orderer/consensus/etcdraft/chain.go Show resolved Hide resolved
if err != nil {
return err
}

//new config metadata was verified above. Additionally need to check new consenters for certificates expiration
for _, c := range changes.AddedNodes {
if err := validateConsenterTLSCerts(c, verifyOpts, false); err != nil {
Copy link
Contributor

@jyellick jyellick Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we should be checking certificate expiration here. For instance, we could have an expired certificate that we want to leave in place while we grow or shrink the consenter set. If we want to check expiration I'd say we need to only check expiration of new certificates.

I'd also note, that the orderer has been modified to perform ID validation not based on cert literals anymore, but rather based on public key, so, in some cases, even if the TLS certificate is expired in the channel config, an orderer with a valid and unexpired TLS certificate with matching public key may successfully be validated using this information.

Copy link
Contributor Author

@kopaygorodsky kopaygorodsky Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jyellick but slicechanges.AddedNodes contains only new nodes(only one node actually), doesn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct, sorry for missing this.

orderer/consensus/etcdraft/util_test.go Show resolved Hide resolved
orderer/consensus/etcdraft/membership.go Show resolved Hide resolved
…expiration is checked only on new consenters.

Improved tests.

Signed-off-by: kopaygorodsky <vlad.kopaygorodsky@gmail.com>
Copy link
Contributor

@jyellick jyellick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is in good enough shape to merge. I've opened https://jira.hyperledger.org/browse/FAB-18257 to address removing the test fixtures once go v1.15 is being used for Fabric.

@jyellick jyellick merged commit 886d3cc into hyperledger:master Oct 6, 2020
@wlahti
Copy link
Contributor

wlahti commented Oct 6, 2020

@jyellick Can you run the backport command to get this in the release-2.2 branch? Thanks! (I assume only maintainers are allowed to do that based on my previous failed attempts to run it myself)

@Mergifyio backport release-2.2

@mergify
Copy link

mergify bot commented Oct 6, 2020

@wlahti is not allowed to run commands

@jyellick
Copy link
Contributor

jyellick commented Oct 6, 2020

@Mergifyio backport release-2.2

mergify bot pushed a commit that referenced this pull request Oct 6, 2020
* FAB-18192 Fixed TLS certs validation for consenters.
Verification of TLS cert against simulated config, not the last one. To achieve that, metadata validator interface was changed, now it requires orderer config instead of just consensus metadata. Also, TLS verification was moved to VerifyMetadata function, it shouldn't have been part of ComputeMembershipChanges. Fixed tests.

Signed-off-by: kopaygorodsky <vlad.kopaygorodsky@gmail.com>

* fixed consenters tests

Signed-off-by: kopaygorodsky <vlad.kopaygorodsky@gmail.com>

* modified VerifyConfigMetadata with ignoreCertExpiration option

Signed-off-by: kopaygorodsky <vlad.kopaygorodsky@gmail.com>

* generation of verifying options based only on simulated config, fixes

Signed-off-by: kopaygorodsky <vlad.kopaygorodsky@gmail.com>

* fixed consenters map

Signed-off-by: kopaygorodsky <vlad.kopaygorodsky@gmail.com>

* Removed ignoreCertExpiration option from VerifyConfigMetadata, certs expiration is checked only on new consenters.
Improved tests.

Signed-off-by: kopaygorodsky <vlad.kopaygorodsky@gmail.com>
(cherry picked from commit 886d3cc)

# Conflicts:
#	orderer/common/msgprocessor/systemchannelfilter_test.go
#	orderer/common/multichannel/chainsupport_test.go
#	orderer/consensus/etcdraft/consenter.go
#	orderer/consensus/etcdraft/consenter_test.go
#	orderer/consensus/etcdraft/util_test.go
@mergify
Copy link

mergify bot commented Oct 6, 2020

Command backport release-2.2: success

Backports have been created

@kopaygorodsky
Copy link
Contributor Author

woohoo, my first PR to fabric is merged :)

@robmurgai
Copy link
Contributor

robmurgai commented Oct 7, 2020 via email

wlahti pushed a commit to wlahti/fabric that referenced this pull request Oct 12, 2020
* FAB-18192 Fixed TLS certs validation for consenters.
Verification of TLS cert against simulated config, not the last one. To achieve that, metadata validator interface was changed, now it requires orderer config instead of just consensus metadata. Also, TLS verification was moved to VerifyMetadata function, it shouldn't have been part of ComputeMembershipChanges. Fixed tests.

Signed-off-by: Vladyslav Kopaihorodskyi <vlad.kopaygorodsky@gmail.com>
jyellick pushed a commit that referenced this pull request Oct 14, 2020
* FAB-18192 Fixed TLS certs validation for consenters. (#1888)

* FAB-18192 Fixed TLS certs validation for consenters.
Verification of TLS cert against simulated config, not the last one. To achieve that, metadata validator interface was changed, now it requires orderer config instead of just consensus metadata. Also, TLS verification was moved to VerifyMetadata function, it shouldn't have been part of ComputeMembershipChanges. Fixed tests.

Signed-off-by: Vladyslav Kopaihorodskyi <vlad.kopaygorodsky@gmail.com>

* IT - update MSP and consenters set in single config update

FAB-18192

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>

* Fix bug in consenter cert validation logic

It was accidentally verifying only the clientCert and
not the cert that was passed in.

FAB-18269

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>

* Update release notes for 2.2.2 for FAB-18192 bug fix

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>

Co-authored-by: Vladyslav Kopaihorodskyi <vlad.kopaygorodsky@gmail.com>
@lucianoacsilva
Copy link

Hello! Is that the new version with this latest fix already available in Docker Hub?

@lindluni
Copy link
Contributor

There is not yet, you will need to build it yourself, or pull it from hyperledger-fabric.jfrog.io/fabric-peer:amd64-2.2-stable which is the unreleased artifact, but the current tip of the 2.2 branch. If you want the latest master you can use the amd64-latest tag instead.

@lucianoacsilva
Copy link

Hello, @btl5037 ,

I've pulled here the hyperledger-fabric.jfrog.io/fabric-peer:amd64-2.2-stable, as you mentioned, but the bug still persists when I try to update the config block with a new adding org:

Error: got unexpected status: BAD_REQUEST -- error applying config update to existing channel 'system-channel': consensus metadata update for channel config update is invalid: verifying tls client cert with serial number 84262169678602556738840170285785102293826956193: x509: certificate signed by unknown authority

Is this bug still persisting with you?

@lindluni
Copy link
Contributor

lindluni commented Oct 26, 2020

@lucianoacsilva Can you pull the image again, artifactory was receiving, but not publishing the updates, it's published now.

@lucianoacsilva
Copy link

@btl5037 , removed the image, pulled it again when starting main network, error still persists:

Error: got unexpected status: BAD_REQUEST -- error applying config update to existing channel 'meat-trace': consensus metadata update for channel config update is invalid: verifying tls client cert with serial number 339235991777995742225504705667499867821380891148: x509: certificate signed by unknown authority

@lindluni
Copy link
Contributor

@lucianoacsilva Can you ping me on chat.hyperledger.org, my ID is BrettLogan

@kopaygorodsky
Copy link
Contributor Author

kopaygorodsky commented Oct 26, 2020

@lucianoacsilva @btl5037 I've built an image from master branch and this fix works. On the other hand, I've tried hyperledger-fabric.jfrog.io/fabric-orderer:amd64-2.2-stable and see this issue.

@lucianoacsilva
Copy link

I see, @kopaygorodsky . How could I build those images from the master branch?

@kopaygorodsky
Copy link
Contributor Author

kopaygorodsky commented Oct 26, 2020

@lucassaldanha
try hyperledger-fabric.jfrog.io/fabric-orderer:amd64-latest
or
git clone fabric
make orderer-docker
and push docker image to your docker registry

@lucianoacsilva
Copy link

Wait, is that the image of the peer or the orderer? @btl5037 mentioned me the hyperledger-fabric.jfrog.io/fabric-peer:amd64-2.2-stable image, not the hyperledger-fabric.jfrog.io/fabric-orderer:amd64-latestone.

@kopaygorodsky
Copy link
Contributor Author

orderer validates block, so you need to use orderer image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants